package model

import (
	"time"

	"gorm.io/gorm"
)

type Users struct {
	Id        *int       `gorm:"column:primaryKey;autoIncrement;id" json:"Id"` //type:*int         comment:租户号                           version:2024-05-17 22:27
	Username  string     `gorm:"column:username" json:"Username"`              //type:string       comment:用户名                           version:2024-05-17 22:27
	Password  string     `gorm:"column:password" json:"Password"`              //type:string       comment:密码                             version:2024-05-17 22:27
	AvatarUrl string     `gorm:"column:avatar_url" json:"AvatarUrl"`           //type:string       comment:头像地址                         version:2024-05-17 22:27
	Phone     string     `gorm:"column:phone" json:"Phone"`                    //type:string       comment:电话                             version:2024-05-17 22:27
	IdNo      string     `gorm:"column:id_no" json:"IdNo"`                     //type:string       comment:身份证                           version:2024-05-17 22:27
	Type      *int       `gorm:"column:type" json:"Type"`                      //type:*int         comment:账号类型;1 普通用户 2.团体用户   version:2024-05-17 22:27
	UpdatedAt *time.Time `gorm:"column:updated_at" json:"UpdatedAt"`           //type:*time.Time   comment:更新时间                         version:2024-05-17 22:27
	CreatedAt *time.Time `gorm:"column:created_at" json:"CreatedAt"`           //type:*time.Time   comment:创建时间                         version:2024-05-17 22:27
	DeletedAt *time.Time `gorm:"column:deleted_at" json:"DeletedAt"`           //type:*time.Time   comment:删除时间                         version:2024-05-17 22:27
	TeamId    *int       `gorm:"column:team_id" json:"TeamId"`                 //type:*int         comment:组织id                           version:2024-05-17 22:27
}

func (u *Users) BeforeCreate(tx *gorm.DB) (err error) {
	u.DeletedAt = nil // 手动设置 deleted_at 字段为 nil
	return nil
}
